不知道大家開發的流程是否與我相同,也有可能是我一開始就先接觸後端的關西,導致我不管如何,都必須先設置基本的路由網址給使用頁面,一方面方便running,一方面就能較清楚的 trace 自己的 code 寫到哪邊~
//反正我很閒
而且當你需要新增其他頁面的時候,再回來加就行了,這對同時開發很多專案的人來說,非常好用~
你想想,當你過了一個禮拜沒碰,再回來時,有多徬徨,我都明白!
所以擁有一個程序去開發你的code,能讓你節省非常多時間!
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import register from '../views/register.vue'
import z from '../components/1.vue'
Vue.use(VueRouter)
const routes = [
{
path: '',
name: 'Home',
component: Home
},
{
path: '/register',
name: 'register',
component: register
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
children:[{
path:"1",
component:z
},
]
}
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router